<?php
class tpl_Form_Select_Date {
	function call($toObj) {
		if (!$Time = Y('Module.List.Editor.Form.Value')) $Time = time();
		$Now = time();
		
		$attr = array(
			'id'=>Y('Module.List.Editor.Form.Name'),
			'class'=> 'Form '.Y('Module.List.Editor.Form.name').' select_date',
			'tabindex'=>Y('Module.List.Editor.Form.TabIndex'),
		);

		$Form = $toObj->DOG_appendChild('select')->attr($attr);
		$Form->attr(array('name'=>Y('Module.List.Editor.Form.Name').'[year]'));
		$DefFlg = true;
		for ($i = date('Y', $Now)-10; $i <= date('Y', $Now)+10; $i++ ) {
			$opt = $Form->DOG_appendChild('option')->attr(array(
				'value'=>$i
			));
			if ($DefFlg && $i == (int)date('Y', $Time)) {
				$opt->attr(array('selected'=>'selected'));
				$opt->text($i);
				$DefFlg = false;
			}
		}
		$toObj->append('年');

		$Form = $toObj->DOG_appendChild('select')->attr($attr);
		$Form->attr(array('name'=>Y('Module.List.Editor.Form.Name').'[month]'));
		$DefFlg = true;
		for ($i = 1; $i <= 12; $i++ ) {
			$opt = $Form->DOG_appendChild('option')->attr(array(
				'value'=>$i
			));
			if ($DefFlg && $i == (int)date('m', $Time)) {
				$opt->attr(array('selected'=>'selected'));
				$opt->text($i);
				$DefFlg = false;
			}
		}
		$toObj->append('月');

		$Form = $toObj->DOG_appendChild('select')->attr($attr);
		$Form->attr(array('name'=>Y('Module.List.Editor.Form.Name').'[day]'));
		$DefFlg = true;
		for ($i = 1; $i <= 31; $i++ ) {
			$opt = $Form->DOG_appendChild('option')->attr(array(
				'value'=>$i
			));
			if ($DefFlg && $i == (int)date('d', $Time)) {
				$opt->attr(array('selected'=>'selected'));
				$opt->text($i);
				$DefFlg = false;
			}
		}
		$toObj->append('日');

	}
}
?>
